var keys = require("./07_keys");
var cb = require("./13_cb");

function findKey(obj, predicate, context) {
  predicate = cb(predicate, context);
  var ks = keys(obj);
  for (var i = 0; i < ks.length; ++i) {
    var currentKey = ks[i];
    if (predicate(obj[currentKey], currentKey, obj)) {
      return currentKey;
    }
  }
}

module.exports = findKey;
